package cn.edu.lingnan.lsqn.model;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.NotEmpty;

@Entity
@Table(name = "t_article")
public class Article {
	private int id;
	private String title;
	private String Content;
	private ArticleType status;
	/**
	 * 投稿时间
	 */
	private Date createDate;
	/**
	 * 审核时间
	 */
	private Date readDate;
	private User user;

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	@NotEmpty(message = "题目不能为空")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@NotEmpty(message = "内容不能为空")
	@Type(type="text")
	public String getContent() {
		return Content;
	}

	public void setContent(String content) {
		Content = content;
	}
	@Enumerated(EnumType.ORDINAL)
	public ArticleType getStatus() {
		return status;
	}

	public void setStatus(ArticleType status) {
		this.status = status;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	@Temporal(TemporalType.TIMESTAMP)
	public Date getReadDate() {
		return readDate;
	}

	public void setReadDate(Date readDate) {
		this.readDate = readDate;
	}

	@ManyToOne
	@JoinColumn(name = "u_id")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Article(int id, String title, String content, ArticleType status, Date createDate, Date readDate,
			User user) {
		this.id = id;
		this.title = title;
		Content = content;
		this.status = status;
		this.createDate = createDate;
		this.readDate = readDate;
		this.user = user;
	}

	public Article(){
		
	}
}
